char->integer, integer->char - conversion between characters and integers

LIBRARY

(import (rnrs))                     ;R6RS
(import (rnrs base))                ;R6RS
(import (scheme r5rs))              ;R7RS
(import (scheme base))              ;R7RS

SYNOPSIS

(char->integer char)
(integer->char sv)

DESCRIPTION

Given a Unicode character, char->integer returns an exact integer between 0 and #xD7FF or between #xE000 and #x10FFFF which is equal to the Unicode scalar value of that character.
R6RS
Sv must be a Unicode scalar value, i.e., a non-negative exact integer object in [0, #xD7FF] ∪ [#xE000, #x10FFFF]. For a Unicode scalar value sv, integer->char returns its associated character.
R7RS
Given an exact integer that is the value returned by a character when char->integer is applied to it, integer->char returns that character.

Given a non-Unicode character, it returns an exact integer greater than #x10FFFF. This is true independent of whether the implementation uses the Unicode representation internally.

RETURN VALUES

Returns a single integer and character object, respectively.

EXAMPLES

(integer->char 32)
   => #\space
(char->integer (integer->char 5000))
   => 5000
(integer->char #\xD800)
   => &assertion exception     ;R6RS

COMPATIBILITY

R6RS defines these procedures in terms of Unicode scalar values. R7RS allows an implementation to support additional characters, and to omit support for some Unicode characters. R5RS defines these procedures so that char<=? on characters matches <= on the corresponding scalar values.

ERRORS

This procedure can raise exceptions with the following condition types:
&assertion (R6RS)
The wrong number of arguments was passed or an argument was outside its domain.
R7RS
The assertions described above are errors. Implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically.

SEE ALSO

char<=?(3scm)

STANDARDS

R4RS, IEEE Scheme, R5RS, R6RS, R7RS

AUTHORS

This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://github.com/schemedoc/manpages/.


Markup created by unroff 1.0sc,    March 04, 2023.